using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication1.Models.Mapping
{
    public class CustomerMap : EntityTypeConfiguration<Customer>
    {
        public CustomerMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.UserName)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.Password)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.Email)
                .IsRequired()
                .HasMaxLength(80);

            this.Property(t => t.Contact)
                .IsRequired()
                .HasMaxLength(25);

            this.Property(t => t.Address_Country)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.Address_State)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.Address_City)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.Address_Street)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Address_Zip)
                .IsRequired()
                .HasMaxLength(8);

            // Table & Column Mappings
            this.ToTable("Customers");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.UserName).HasColumnName("UserName");
            this.Property(t => t.Password).HasColumnName("Password");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.Contact).HasColumnName("Contact");
            this.Property(t => t.Address_Country).HasColumnName("Address_Country");
            this.Property(t => t.Address_State).HasColumnName("Address_State");
            this.Property(t => t.Address_City).HasColumnName("Address_City");
            this.Property(t => t.Address_Street).HasColumnName("Address_Street");
            this.Property(t => t.Address_Zip).HasColumnName("Address_Zip");
        }
    }
}
